package com.yihen.controller;

import com.yihen.bean.Weight;
import com.yihen.dto.Result;
import com.yihen.service.WeightService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/weight")
public class WeightController {

    @Autowired
    WeightService weightService;

    // 添加记录
    @PostMapping("/add")
    Result addWeight(@RequestBody Weight weight) {
        return weightService.addWeight(weight);
    }

    // 获取特定时间段内记录
    @GetMapping("/get/{userId}/{startDate}/{endDate}")
    Result getRecord(@PathVariable Long userId, @PathVariable String startDate, @PathVariable String endDate) {
        return weightService.getWeightByDate(userId, startDate, endDate);
    }
}
